<!DOCTYPE html>
<html>
	<head>
		<meta charset="UTF-8">
		<title>js_dom练习02</title>
	</head>
	<body>
		<script type="text/javascript">
			function doFocus(){
				var user = document.getElementById("user");
				if(user.value=="10xxxxxx"){
					user.value="";
				}
			}
			function doBlur(user){
				if(user.value.substr(0,2) !=10 || isNaN(user.value)){
					alert("格式错误，请重新输入");
					user.value="";
				}
				}
		</script>
		<form action="#" method="post">
		请输入账号：<input type="text" id="user" value="10xxxxxx" onfocus="doFocus()" onblur="doBlur(this)"/>输入格式：10xxxxxx<br />
		请输入密码：<input type="password" id="password" />
		</form>
	</body>
</html>
